<%@ page language="java"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
    <base href="<%=basePath%>">
    <title>材料库存详情</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <link rel="stylesheet" type="text/css" href="<%=basePath%>js/bootstrap-3.3.6/dist/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="<%=basePath%>css/bootstrapValidator.css"/>
    <link rel="stylesheet" type="text/css" href="<%=basePath%>css/mydialog.css"/>
    <link rel="stylesheet" type="text/css" href="<%=basePath%>css/style.css"/>
    <script type="text/javascript" src="<%=basePath%>js/common/jquery-2.1.0.js" charset="utf-8"></script>

    <script type="text/javascript" src="<%=basePath%>js/common/dialog.3.1.min.js"></script>

<body>
<div id="index-hav2">
    <div class="index-hav-right" id="index-hav-right-clear">
        <div class="row">
            <div class="col-md-9">
                <span id="icon-house"> </span><span>首页</span>
                <span>></span><span>材料库存</span>
                <span>></span><span>详情</span>
            </div>
            <div class="bank-box">
                <div class="lianlian platform">
                    <!-- 搜索 -->
                    <div class="col-md-4" style="width: 95%;height: 50px;line-height: 50px; border: 0px solid red;margin-left: 20px;">
                        部品番号:<b>${modelCode }</b>


                        <div class="search-form-btn search-form-input" style="float: right">
                            <button type="button" id="closebut" class="btn btn-sm btn-success" onclick="window.location.href='<%=path%>/bus/meter/returnMeterGive?url=<%=path%>/bus/meter/list&flg=queryPageBusModelMeter'">返回</button>
                        </div>
                    </div>

                    <div class="col-md-12">
                        <table class="control-tatle table table-striped table-bordered table-hover">
                            <thead class="financing-thead">
                            <tr>
                                <th>序号</th>
                                <th>用途</th>
                                <th>支给数量</th>
                                <th>支给时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <c:if test="${not empty modelMeterPlans}">
                                <c:forEach items="${modelMeterPlans }" var="meter" varStatus="r">
                                    <tr>
                                        <td>${r.index+1 }</td>
                                        <td>${meter.useFor }</td>
                                        <td>${meter.giveAmount }</td>
                                        <td><fmt:formatDate value="${meter.giveTime}" pattern="yyyy-MM-dd"/></td>
                                        <td>
                                            <c:if test="${meter.status == '0'}">
                                                <button class="btn btn-sm btn-success" data-toggle="modal"
                                                        data-target="#myModalAdd" onclick="getDetails(${meter.id })">
                                                    修改
                                                </button>
                                            </c:if>

                                        </td>
                                    </tr>
                                </c:forEach>
                            </c:if>
                            <c:if test="${empty modelMeterPlans}">
                                <tr>
                                    <td colspan="11"><label class="control-label text-center">无记录</label></td>
                                </tr>
                            </c:if>
                            </tbody>
                            <tr style="background:#f8f8f8">
                                <%--<td colspan="12">--%>
                                <%--<jsp:include page="/WEB-INF/jsp/page.jsp"></jsp:include>--%>
                                <%--</td>--%>
                            </tr>
                        </table>

                    </div>
                </div>
            </div>
        </div>

        <!-- 添加 模态框（Modal） -->
        <div class="modal fade" id="myModalAdd" tabindex="-2" role="dialog" aria-labelledby="myModalLabelAdd"
             aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content" style="border: 0px solid red; width: 50%;margin: auto;">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                            &times;
                        </button>
                        <h5 class="modal-title" id="myModalLabelAdd">
                            修改
                        </h5>
                    </div>
                    <form id="defaultForm" action="<%=path%>/bus/meter/toLssuedDetails/save" class="form-horizontal"
                          method="post">
                        <div class="modal-body">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">用途:</label>
                                <div class="col-sm-6">
                                    <select class=" form-control input-sm"
                                            name="useFor" id="useFor">
                                        <option value="取样">取样</option>
                                        <option value="调试">调试</option>
                                    </select>
                                </div>

                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">支给数量:</label>
                                <div class="col-sm-6">
                                    <input type="text" class="form-control" id="giveAmount" name="giveAmount"
                                           placeholder="" required/>
                                </div>

                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">支给时间:</label>
                                <div class="col-sm-6">
                                    <input type="text" class="Wdate form-control" name="giveTime" id="giveTime"
                                           onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})" value="">
                                </div>
                            </div>
                        </div>
                        <input type="hidden" name="id" id="id"/>
                        <input type="hidden" name="status" id="status"/>
                        <input type="hidden" name="modelCode" id="modelCode" value="${modelCode}"/>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                            </button>
                            <button type="submit" class="btn btn-sm btn-success" onclick="saveDetails('0')">保存</button>
                            <button type="submit" class="btn btn-sm btn-success" onclick="saveDetails('1')">提交</button>
                        </div>
                    </form>
                </div><!-- /.modal-content -->
            </div><!-- /.modal -->
        </div><!-- /.end modal -->
    </div>
</div>

<div id="gray-screen"></div>

</body>
<script type="text/javascript" src="<%=basePath%>js/validate/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="<%=basePath%>js/rem.js" charset="utf-8"></script>
<script type="text/javascript" src="<%=basePath%>js/validate/bootstrapValidator.js"></script>
<script type="text/javascript" src="<%=basePath%>js/validate/zh_CN.js"></script>
<script type="text/javascript" src="<%=basePath%>js/bootstrap-3.3.6/dist/js/bootstrap.min.js" charset="utf-8"></script>
<script type="text/javascript" src="<%=basePath%>js/My97DatePicker/WdatePicker.js"></script>
<script>
    function getDetails(id) {
        $.ajax({
            type: "get",
            url: "<%=path%>/bus/meter/toLssuedDetails/toEdit?id=" + id,
            dataType: "json",
            success: function (data) {
                var useFor = data.modelMeterPlan.useFor;
                var giveAmount = data.modelMeterPlan.giveAmount;
                var giveTime = data.modelMeterPlan.giveTime;
                var seleuseFor = document.getElementById("useFor");
                for (i = 0; i < seleuseFor.length; i++) {//给select赋值
                    if (useFor == seleuseFor.options[i].text) {
                        seleuseFor.selectedIndex = i;
                        break;
                    }
                }
                $("#giveAmount").val(giveAmount);
                var date = new Date(giveTime);
                var year = date.getFullYear();//年
                var month = date.getMonth() + 1;//月份（月份是从0~11，所以显示时要加1）
                var day = date.getDate();//日期
                var str = year + '-' + month + '-' + day;
                $("#giveTime").val(str);
                $("#id").val(id);
            }
        });
    }

    function saveDetails(num) {
        $("#status").val(num);
    }

</script>
</html>